/**
 * Project Name:nplus1
 * File Name:ImageUploadController.java
 * Package Name:com.gamma.nplus1.common.web
 * Date:2017年5月26日下午10:10:10
 * Copyright (c) 2017, nplus1 Co., Ltd. All Rights Reserved.
 *
*/

package com.gamma.nplus1.common.web;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.fileupload.FileUploadException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * ClassName:ImageUploadController <br/>
 * Function: 图片上传控制器. <br/>
 * Date:     2017年5月26日 下午10:10:10 <br/>
 * @author   jeno
 * @version  
 * @since    JDK 1.7
 */
@Controller
@RequestMapping(value = "${adminPath}/image")
public class ImageUploadController extends BaseController {

	/**
	 * upload:(单图上传). <br/>
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 * @throws FileUploadException
	 */
	@SuppressWarnings("rawtypes")
	@RequestMapping(method = RequestMethod.POST, value = "upload")
	@ResponseBody
	public void upload(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException, FileUploadException {
		Map<String, Object> msg = new HashMap<String, Object>();
		msg.put("error", 0);
		msg.put("url", "/nplus1/static/images/2.png");
		
		renderString(response, msg);
	}
	
	/**
	 * 
	 * multiUpload:(多图上传). <br/>
	 *
	 * @author jeno
	 * @param request
	 * @param response
	 * @throws ServletException
	 * @throws IOException
	 * @throws FileUploadException
	 * @since JDK 1.7
	 */
	@SuppressWarnings("rawtypes")
	@RequestMapping(method = RequestMethod.POST, value = "multiupload")
	@ResponseBody
	public void multiUpload(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException, FileUploadException {
		Map<String, Object> msg = new HashMap<String, Object>();
		msg.put("error", 0);
		msg.put("url", "/nplus1/static/images/2.png");
		
		renderString(response, msg);
	}
}

